package com.example.test.chapter9.flipper;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ViewFlipper;

import com.example.test.R;
import com.example.test.chapter9.MainChapter9;

public class FlipperBActivity extends Activity {
	static final String[] WORLDCUP16 = new String[] { "Argentina", "Brazil",
			"Chile", "England", "Germany", "Ghana", "Japan", "Mexico",
			"Netherlands", "Paraguay", "Portugal", "Slovakia", "Slovenia",
			"South Korea", "Spain", "United States", "Uruguay" };
	ViewFlipper flipper;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.flipper1);
		flipper = (ViewFlipper) findViewById(R.id.detailsFlipper1);
		flipper.setInAnimation(AnimationUtils.loadAnimation(this,
				R.anim.push_up_in));
		flipper.setOutAnimation(AnimationUtils.loadAnimation(this,
				R.anim.push_up_out));
		for (String item : WORLDCUP16) {
			Button button = new Button(this);
			button.setText(item);
			flipper.addView(button, new LinearLayout.LayoutParams(
					LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
		}
		flipper.setFlipInterval(2000);
		flipper.startFlipping();
		Button btn = (Button) findViewById(R.id.backpage);
		btn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(getApplicationContext(),
						MainChapter9.class);
				startActivity(intent);
				finish();
			}
		});
	}
}
